<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/DefaultTemplate.xhtml">
        <ui:define name="content">
            <h:panelGroup id="messagePanel" layout="block">
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
            </h:panelGroup>
            <h:form >
                <p:panel header="New Invoice: " style="text-align: center">
                    <h:panelGrid > 
                        <h:outputLabel value="Receive Invoice From:" for="plar" />  
                        <p:autoComplete id="plar" value="#{vendorInvoiceEntityController.text}"  
                                        completeMethod="#{vendorInvoiceEntityController.complete}"  

                                        />  
                         <p:watermark for="plar" value="Enter company name" />  
                        <h:outputText id="player" value="#{vendorInvoiceEntityController.text}"/>
                        <p:commandButton  action="#{vendorInvoiceEntityController.update}" value="Find matching order" update="panel,books"/>              



                    </h:panelGrid>  
                </p:panel> 
                <p:separator style="width:300px;height:10px" /> 

                <p:panel header="List of suggested matching Orders:" style="text-align: center">
                    <p:outputPanel id="books"> 
                        <p:dataTable  value="#{vendorInvoiceEntityController.suggest}" var="rmq" paginator="true" rows="10"
                                      selection="#{vendorInvoiceEntityController.selectedRpo}" 
                                      >

                            <p:column selectionMode="single" />  


                            <p:column sortBy="#{rmq.rmq.vendor.companyName}" filterBy="#{rmq.rmq.vendor.companyName}">    <f:facet name="header">  
                                    <h:outputText value="Vendor Name" /> </f:facet>
                                <h:outputText value="#{rmq.rmq.vendor.companyName}" /> </p:column>

                            <p:column sortBy="#{rmq.rmq.rawMaterial.productName}" filterBy="#{rmq.rmq.rawMaterial.productName}">    <f:facet name="header">  
                                    <h:outputText value="Raw Material:" /> </f:facet>
                                <h:outputText value="#{rmq.rmq.rawMaterial.productName}" /> </p:column>
                                
                     <p:column sortBy="#{rmq.status}" filterBy="#{rmq.status}">    <f:facet name="header">  
                                    <h:outputText value="Status:" /> </f:facet>
                                <h:outputText value="#{rmq.status}" /> </p:column>
                            
                            <p:column>    <f:facet name="header">  
                                    <h:outputText value="Date Purchased:" /> </f:facet>
                                <h:outputText value="#{rmq.createdAt}" > 
                                    <f:convertDateTime pattern="dd/MM/yyyy" />
                                </h:outputText>
                            </p:column>
                        </p:dataTable> 
                    </p:outputPanel>
                    <br/>
          
                </p:panel>
                <br/>
                      <p:commandButton ajax="false" action="#{vendorInvoiceEntityController.proceed}" value="Proceed"  
                             />
            </h:form>    
        </ui:define>
    </ui:composition>



</html>
